using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAO;

namespace BUS
{
    public class EmployeeBUS
    {
        #region 1. Inserting
        public static bool InsertEmployee(EmployeeDTO emp)
        {
            if (EmployeeDAO.CheckEmployeeByID(emp.EmployeeID)==true
                &&EmployeeStyleDAO.CheckEmployeeStyleByID(emp.EmployeeStyle)==false)
            {
                return false;               
            }
            return EmployeeDAO.InsertEmployee(emp);
        }
        #endregion
        #region 2. Updating
        public static bool UpdateEmployee(EmployeeDTO emp)
        {
            if (EmployeeDAO.CheckEmployeeByID(emp.EmployeeID)
                &&EmployeeStyleDAO.CheckEmployeeStyleByID(emp.EmployeeStyle)==true)
            { 
                return EmployeeDAO.UpdateEmployee(emp);
            } 
            return false;

        }
        #endregion
        #region 3. Deleting
        public static bool DeleteEmployeeByID(String employeeID)
        {
            if (EmployeeDAO.CheckEmployeeByID(employeeID))
            {
                return EmployeeDAO.DeleteEmployeeByID(employeeID);                              
            }
            return false;
        }
        #endregion
        #region 4. Retrieving
        public static List<EmployeeDTO> SelectEmployeeByEmployeeStyle(int employeeStyle)
        {
            if (EmployeeStyleDAO.CheckEmployeeStyleByID(employeeStyle))
            {
                return EmployeeDAO.SelectEmployeeByEmployeeStyle(employeeStyle);
            }
            return null;
        }
        public static List<EmployeeDTO> SelectEmployeeAll()
        {
            return EmployeeDAO.SelectEmployeeAll();
        }
        public static EmployeeDTO SelectEmployeeByID(String employeeID)
        {
            if (EmployeeDAO.CheckEmployeeByID(employeeID))
            {
                return null;
            }
            return EmployeeDAO.SelectEmployeeByID(employeeID);
        }
        #endregion
    }
}
